#ifndef CHAIN_H 
#define CHAIN_H

#include <vector>
#include <string>
#include "Permutation.h"
#include "XmlDefinitions.h"
#include "./Markup/Markup.h"

using std::string;

class Chain
{
public:
	Chain(int maxIntersection): m_MaxIntersection(maxIntersection) {};
	void PushPermutation(Permutation* perm); // Add permutation to end of list
	Permutation * PopPermutation(); // Removes last permutation added
	bool IsLegalToAdd(const Permutation* perm) ; // Does perm have a small intersection with all permutations in chain
	void Save(CMarkup &xml);
	void SetName(string name) { m_Name = name; };
	void RemoveIntersections();
	const vector<Permutation*> GetPermutations() const { return m_Permutations; }
	int GetLength() const { return m_Permutations.size(); };
	Chain *Clone(); // Creates a copy of this chain for cleaning operations before save
	bool operator== (const Chain &other) const;
	bool operator!= (const Chain &other) const;

private:
	vector<Permutation*> m_Permutations; // We use a vector and not a queue despite interface to go over all permutations
	int m_MaxIntersection; // Largest intersection that a permutation can have with a permutation in the chain and can still be added
	string m_Name;

	
	

};

#endif